home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / netuser.zip / GETID.PAS < prev   
Pascal/Delphi Source File  |  1993-01-04  |  4KB  |  150 lines

  1. Program  Novell_API_Examples;
  2.  
  3. { Misc. Novell Advanced Netware 2.1+ API examples to retrieve info on the
  4.   user who is running this program
  5. }
  6.  
  7. USES   DOS, CRT;
  8.  
  9. CONST
  10.   HexDigit: array [0..15] of char = '0123456789ABCDEF';
  11.   Days_Of_Week   : Array[0..6] of string = ('Sunday','Monday','Tuesday',
  12.                                             'Wednesday','Thursday','Friday',
  13.                                             'Saturday');
  14.  
  15.  
  16. TYPE
  17.   string2 = STRING[2];
  18.   string4 = STRING[4];
  19.  
  20.  
  21. VAR
  22.   Reg          : DOS.Registers;
  23.   RCode        : Integer;
  24.   Connect      : Byte;
  25.   Address      : String;
  26.  
  27.  
  28. function HexByte(B: byte): string2;
  29.   begin
  30.     HexByte := HexDigit[B shr 4] + HexDigit[B and $F];
  31.   end;
  32.  
  33.  
  34. function Hex(I: integer): string4;
  35.   begin
  36.     Hex := HexByte(hi(I)) + HexByte(lo(I));
  37.   end;
  38.  
  39.  
  40. Function Get_Connection_Number : Integer;
  41.   { |
  42.     | Returns the connection number for the current session
  43.     |
  44.   }
  45.   begin
  46.     Reg.AH := $DC;
  47.     intr($21,Reg);
  48.     Get_Connection_Number := Reg.AL;
  49.   end;
  50.  
  51.  
  52. Function Get_Station_Address(var Address: String): Integer;
  53.   { |
  54.     |  Returns the Physical Station Address (NIC Number)
  55.     |
  56.   }
  57.   var
  58.     S1, S2, S3 : String;
  59.   begin
  60.     Reg.AH := $EE;
  61.     intr($21,Reg);
  62.     Address := Hex(Reg.CX) + Hex(Reg.BX) + Hex(Reg.AX);
  63.     Get_Station_Address := $00;
  64.   end;
  65.  
  66.  
  67. Function Get_Login_Name : String;
  68.   { |
  69.     |  Who's calling?
  70.     |
  71.   }
  72.   var
  73.     Reg           : DOS.REGISTERS;
  74.     Loop,
  75.     Connection    : Byte;
  76.     TmpStr        : String;
  77.     Request_Buf   : Record
  78.                       BufLen     : Integer;
  79.                       SubFunc    : Byte;
  80.                       Connection : Byte;
  81.                     end;
  82.     Reply_Buf     : Record
  83.                       BufLen     : Integer;
  84.                       Obj_ID     : LongInt;
  85.                       Obj_Type   : Integer;
  86.                       Obj_Name   : Array[1..48] of char;
  87.                       Login_Time : Record
  88.                                      Year   : Byte;
  89.                                      Month  : Byte;
  90.                                      Day    : Byte;
  91.                                      Hour   : Byte;
  92.                                      Minute : Byte;
  93.                                      Second : Byte;
  94.                                      Day_No : Byte;
  95.                                    end;
  96.                   end;
  97.  
  98.   begin
  99.     TmpStr := '';
  100.     RCode := 0;
  101.     Connect := Get_Connection_Number;
  102.     fillchar(Request_Buf,sizeof(Request_Buf),0);
  103.     fillchar(Reply_Buf,sizeof(Reply_Buf),0);
  104.  
  105.     Request_Buf.SubFunc := $16;
  106.     Request_Buf.Connection := Connect;
  107.     Request_Buf.BufLen := sizeof(Request_Buf);
  108.     Reply_Buf.BufLen := sizeof(Reply_Buf);
  109.     Reg.AH := $E3;
  110.     Reg.DS := seg(Request_Buf);
  111.     Reg.SI := ofs(Request_Buf);
  112.     Reg.ES := seg(Reply_Buf);
  113.     Reg.DI := ofs(Reply_Buf);
  114.     intr($21,Reg);
  115.     Loop := 1;
  116.     while ((Reply_Buf.Obj_Name[Loop] <> #0) and (Loop <= 48)) do
  117.       begin
  118.         TmpStr := TmpStr + Reply_Buf.Obj_Name[Loop];
  119.         inc(loop);
  120.       end;
  121.     Get_Login_Name := TmpStr;
  122.   end;
  123.  
  124.  
  125. Procedure Pause;
  126.   var
  127.     ch : char;
  128.   begin
  129.     writeln;
  130.     write('Press Any Key To Continue ');
  131.     ch := readkey;
  132.     writeln;
  133.   end;
  134.  
  135.  
  136. BEGIN
  137.   clrscr;
  138.   writeln('Get Novell Station Info  - (C) Rick Ryan, 1989');
  139.   writeln;
  140.   Connect := Get_Connection_Number;
  141.   Writeln('  Connection ID: ', Connect);
  142.  
  143.   RCode := Get_Station_Address(Address);
  144.   writeln('Station Address: ',Address,'  With ErrCode of ', RCode);
  145.  
  146.   writeln('Login Name = ',Get_Login_Name);
  147.  
  148.   Pause;
  149.  
  150. END.